<%@page import="com.common.util.SN_GUID"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	//表格动态Id
	request.setAttribute("basePath", basePath);
	request.setAttribute("file_plugin_id",
			(int) (Math.random() * 100000));
	request.setAttribute("uploadFile",
			request.getParameter("uploadFile"));
	request.setAttribute("fn_getFile",request.getParameter("fn_getFile"));
	request.setAttribute("fn_setFileGroupId",request.getParameter("fn_setFileGroupId"));
	request.setAttribute("fn_getFileGroupId",request.getParameter("fn_getFileGroupId"));
	request.setAttribute("accept", request.getParameter("accept"));
	request.setAttribute("fileGroupId", SN_GUID.getUUID());
	//限制文件类型
	request.setAttribute("getFileType",request.getParameter("getFileType"));
	
%>
<script type="text/javascript">
var fileGroupId${file_plugin_id}="${fileGroupId}";
/**
 如果当前上传不设置fileGroupId ,那么在上传页面会自动生成一个guid
**/
function ${fn_setFileGroupId==null ?"__":fn_setFileGroupId}(GroupId){
	fileGroupId${file_plugin_id}=GroupId;
}
/**
获取上传页面的fileGroupId,在getFile()方法中引用
**/
function ${fn_getFileGroupId==null ?"__":fn_getFileGroupId}(){
	return fileGroupId${file_plugin_id};
}
/**

文件上传
**/
function uploadFile_${file_plugin_id}(){
	//赋值文件组value
	SN.getWindowByUrl("文件上传",600,300,"${basePath}page/common/File/toAdd",{"fn":"getFile_${file_plugin_id}","accept":"${accept}","fileGroupId":fileGroupId${file_plugin_id},"type":"${getFileType}"});
}
//上传文件后,点确认,会调用这个方法
function fn_getFile_${file_plugin_id}(data){
	try{
		${fn_getFile}(data);
	}catch (e){
 		alert("系统插件错误:找不到方法${fn_getFile}");
 		throw e;
	}
	
}
</script>
<button onclick="uploadFile_${file_plugin_id}()" class="btn btn-primary" type="button">
	<span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>
	&nbsp;
	<span>上传文件</span>
</button>
